package com.kxxnzstdsw.plugins

import com.kxxnzstdsw.schedule.scan
import io.ktor.server.application.*
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import org.koin.ktor.ext.getKoin
import org.koin.ktor.ext.inject
import org.quartz.Scheduler

@OptIn(DelicateCoroutinesApi::class)
fun Application.configureQuartz() {
  val scheduler by inject<Scheduler>()
  GlobalScope.launch {
    scheduler.apply {
      scan(getKoin(), "com.kxxnzstdsw.schedule.job")
    }.start()
  }
}
